package cn.donting.jme.edit.state;

import com.jme3.app.Application;
import com.jme3.app.state.AbstractAppState;
import com.jme3.app.state.AppStateManager;
import com.jme3.input.CameraInput;
import com.jme3.input.InputManager;
import com.jme3.input.KeyInput;
import com.jme3.input.MouseInput;
import com.jme3.input.controls.*;
import com.jme3.math.Matrix3f;
import com.jme3.math.Quaternion;
import com.jme3.math.Vector2f;
import com.jme3.math.Vector3f;
import com.jme3.renderer.Camera;
import lombok.extern.slf4j.Slf4j;

import static com.jme3.input.CameraInput.*;

/**
 * 场景基础移动 控制
 */
@Slf4j
public class SceneMoveAppState extends AbstractAppState implements ActionListener,AnalogListener  {
    private Camera camera;
    private InputManager inputManager;
    private EditFlyByCamera editFlyByCamera;
    private Vector2f startPosition;
    @Override
    public void initialize(AppStateManager stateManager, Application app) {
        inputManager = app.getInputManager();
        this.camera = app.getCamera();
        editFlyByCamera=new EditFlyByCamera(camera);
        editFlyByCamera.registerWithInput(app.getInputManager());
        super.initialize(stateManager, app);
        inputManager.addMapping("click",new MouseButtonTrigger(MouseInput.BUTTON_LEFT));
        inputManager.addListener(this,"click");
    }

    @Override
    public void onAction(String name, boolean isPressed, float tpf) {
    }

    @Override
    public void onAnalog(String name, float value, float tpf) {

    }
}
